<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
		<meta http-equiv="Pragma" content="no-cache"> 
		<meta http-equiv="Cache-Control" content="no-cache"> 
		<meta http-equiv="Expires" content="0"> 
		<title>后台管理</title>
		<link href="css/login.css" rel="stylesheet" type="text/css">
	</head>
<body>
<div class="login_box">
      <div class="login_l_img"><img src="img/login-img.png"></div>
      <div class="login">
          <div class="login_logo"><a href="#"><img src="img/login_logo.png"></a></div>
          <div class="login_name">
               <p>后台管理系统</p>
          </div>
          
              <input name="username" type="text" value="用户名" maxlength="11" id="username" onfocus="this.value=''" onblur="if(this.value==''){this.value='用户名'}">
              <span id="password_text" onclick="this.style.display='none';document.getElementById('password').style.display='block';document.getElementById('password').focus().select();">密码</span>
				<input name="password" type="password" id="password" style="display:none;" onblur="if(this.value==''){document.getElementById('password_text').style.display='block';this.style.display='none'};">
              <input value="登录" style="width:100%;" type="submit" id="submitBtn">
         
      </div>
      <div class="copyright">某某有限公司 版权所有©2016-2018 技术支持电话：000-00000000</div>
      <script type="text/javascript" src="js/jquery.js" ></script>
      <script type="text/javascript" src="js/jquery.cookie.js" ></script>
      <script>
      	$("#submitBtn").on("click",function(){
      		var phone = $("#username").val(),
      			pwd   = $("#password").val();
      			if(phone =="" || pwd == ""){
      				alert("账号密码不能为空!");
      			}else{
      				$.ajax({
      				type:"post",
      				url:"http://39.108.164.20/device/SysUser/Login",
      				dataType:"json",
      				data:{
      					phone:phone,
      					pwd:pwd
      				},
      				success:function(res){
      					console.log(res);
      					if(res.result.success == 0){
      						var uid = res.result.data.uuid,
      							pet_name = res.result.data.pet_name,
      							phone_number = res.result.data.phone_number,
      							clerk_name = res.result.data.clerk_name,
      							clerk_id = res.result.data.clerk_id;
      							$.cookie("uid",uid);
      							$.cookie("clerkId",clerk_id);
      							$.cookie("userName",pet_name);
      							$.cookie("phone",phone_number);
      							$.cookie("clerk",clerk_name);
      							location.href = "nav.html";
      					}else{
      						alert("账号或密码错误!");
      					}
      				}
      				});
      			}	
      	})
      	//绑定键盘事件
      	$("body").on("keydown",function(e){
      		if(e.keyCode==13){
      			$("#submitBtn").trigger("click");
      		}
      	})
      </script>
</div>
</body>
</html>
